<template>
  <component :is="Comp" />
<!--  路由包装页     在同一路由下根据角色切换组件-->
</template>

<script setup name="DashboardSwitcher">
import { computed, defineAsyncComponent } from 'vue'
import useUserStore from '@/store/modules/user'

const user = useUserStore()

const Comp = computed(() => {
  const roles = user.roles || []
  const isAdmin = roles.includes('admin') || roles.includes('ROLE_ADMIN')
  return isAdmin
    ? defineAsyncComponent(() => import('@/views/admin/dashboard.vue'))
    : defineAsyncComponent(() => import('@/views/index.vue'))
})
</script>

<style scoped lang="scss">

</style>